<template>
  <div>
    <div class="maincss">
      <el-row>
        <el-card>
          <!-- <searchBox title='消耗记录' :btn='btn' @func='showBtn' @sendParent="queryListByParams" /> -->
          <el-card class="gray-card no-border no-margin-top" shadow="never">
            <el-row class="type">
              <el-col span="3">
                <el-input
                  v-model="queryParams.materialNo"
                  placeholder="耗材名称、编号"
                  clearable
                ></el-input>
              </el-col>
              <el-col span="3">
                <el-input
                  v-model="queryParams.batchNo"
                  placeholder="耗材批号"
                  clearable
                ></el-input>
              </el-col>
              <el-col span="3">
                <el-select
                  v-model="queryParams.type"
                  placeholder="选择耗材类型"
                  class=""
                >
                  <el-option
                    v-for="item in type"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-col>

              <el-col span="3">
                <el-date-picker
                  v-model="queryParams.useTime"
                  type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  placeholder="选择使用时间"
                >
                </el-date-picker>
              </el-col>

              <el-col span="3">
                <el-button @click="handleLoadAndQuery()" class="btn"
                  >查询</el-button
                >
              </el-col>
            </el-row>
            <el-table
              v-loading="loading"
              :data="checkList"
              style="width: 100%;"
            >
              <el-table-column
                label="耗材编号"
                align="center"
                prop="materialNo"
                :show-overflow-tooltip="true"
              />
              <el-table-column
                label="耗材名称"
                align="center"
                prop="materialName"
                :show-overflow-tooltip="true"
              />
              <el-table-column
                label="耗材批号"
                align="center"
                prop="batchNo"
                :show-overflow-tooltip="true"
              />
              <el-table-column label="耗材类型" align="center" prop="type">
                <template slot-scope="scope">
                  <sapn v-if="scope.row.type === 1">试剂</sapn>
                  <sapn v-if="scope.row.type === 2">质控品</sapn>
                </template>
              </el-table-column>
              <el-table-column
                label="生产厂商"
                align="center"
                prop="manufacturer"
                :show-overflow-tooltip="true"
              />
              <el-table-column
                label="应用科室"
                align="center"
                prop="deptName"
                :show-overflow-tooltip="true"
              />
              <el-table-column
                label="应用项目"
                align="center"
                prop="projectName"
              />
              <el-table-column label="使用时间" align="center" prop="useTime" />
              <el-table-column label="使用者" align="center" prop="user" />
            </el-table>
          </el-card>
          <!--          <pagination v-show="total>0" :total="total" :page.sync="pageNum" :limit.sync="pageSize" />-->
          <div class="pagination-container">
            <pagination
              v-show="total > 0"
              :total="total"
              :page.sync="queryParams.pageNum"
              :limit.sync="queryParams.pageSize"
              @pagination="handleLoadAndQuery"
            />
          </div>
        </el-card>
      </el-row>
    </div>
  </div>
</template>

<script>
import { materialLogsList } from "../../../api/business/materialLogs";
export default {
  name: "expend-record",
  components: {},
  data() {
    return {
      btn: {
        expendRecord: true,
        add: false,
        reg: false,
        down: false,
        export: false,
        imp: false
      },
      checkList: [],
      loading: false,
      redirect: undefined,
      activeName: "1",
      deviceInfo: {},
      type: [
        {
          value: "",
          label: "选择消息类型"
        },
        {
          value: "1",
          label: "试剂"
        },
        {
          value: "2",
          label: "质控品"
        }
      ],
      value: "",
      total: 5,
      queryParams: {
        pageNum: 1,
        pageSize: 10
      }
    };
  },
  watch: {},
  created() {
    this.handleLoadAndQuery();
  },
  methods: {
    toDeviceInfo(id) {
      // this.$router.push({path:"/device/deviceInfo/index"});
    },
    handleLoadAndQuery() {
      this.loading = true;
      materialLogsList(this.queryParams).then(response => {
        this.loading = false;
        this.checkList = response.rows;
        this.total = response.total;
      });
    }
  }
};
</script>
